package com.chinaisafe.user.vo.request;

import com.chinaisafe.base.common.vo.request.PageReqVo;
import com.chinaisafe.base.common.validated.AddGroup;
import com.chinaisafe.base.common.validated.UpdateGroup;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.chinaisafe.user.entity.SysLoginLog;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
 * SysLoginLogReqVO
 * Description：登录日志请求值对象
 *
 * @author xuefu.shu
 * @date  2024-07-12 09:55:54
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysLoginLogReqVO", description = "登录日志请求值对象")
public class SysLoginLogReqVO extends PageReqVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    @NotNull(groups = UpdateGroup.class, message = "主键id不能为空" )
    private Long id;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "用户id")
    private Long sysUserId;

    @Schema(description = "登录账号")
    private String loginName;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "微信openid")
    private String wxOpenid;

    @Schema(description = "认证方式")
    private String authType;

    @Schema(description = "登录ip")
    private String loginIp;

    @Schema(description = "登录地点")
    private String loginAddress;

    @Schema(description = "客户端类型")
    private String client;

    @Schema(description = "登录状态(成功/失败)")
    private Boolean status;

    @Schema(description = "访问时间")
    private LocalDateTime loginTime;


    /**
     * 将请求值对象装换为实体
     * @return SysLoginLog
     * @author xuefu.shu
     * @date 2024-07-12 09:55:54
     */
    public SysLoginLog convertToEntity() {
        SysLoginLog entity = new SysLoginLog();
        entity.setId(this.id);
        entity.setVersion(this.version);
        // 给实体对应的字段赋值 可根据实际业务删减
        entity.setSysUserId(this.sysUserId);
        entity.setLoginName(this.loginName);
        entity.setMobile(this.mobile);
        entity.setWxOpenid(this.wxOpenid);
        entity.setAuthType(this.authType);
        entity.setLoginIp(this.loginIp);
        entity.setLoginAddress(this.loginAddress);
        entity.setClient(this.client);
        entity.setStatus(this.status);
        entity.setLoginTime(this.loginTime);
        return entity;
    }
}
